package ControllerLayer;



import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The test class testAdressCtr.
 *
 * @author  Gruppe 4, DM84
 * @version (a version number or a date)
 */
public class testAddressCtr
{
    private ControllerLayer.AddressCtr addressC1;
    
    /**
     * Default constructor for test class testAdressCtr
     */
    public testAddressCtr()
    {
        addressC1 = addressC1.getInstance();
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    @Before
    public void setUp()
    {
        
        addressC1.createCustomer("Anders", "Karljohanvej 7", "89874521", "larskarlson@gmail.com", 100.0, 20.0);
        addressC1.createEmployee("Lars", "Sønderholmsvej 8",  "30285018", "andersh@gmail.com","abc123");
        addressC1.createEmployee("Flemming", "Sønderholmvej 18", "93456643", "flemminga@gmail.com", "602090");
        addressC1.createCustomer("Jakob", "Albertvej 8", "28309012", "jakoba@gmail.com", 100.0, 10.0);
        
        //         assertNotNull(addressC1.getPerson(3));
      
        addressC1.deletePerson(3);
        addressC1.deletePerson(4);
     
       
    }
    

    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    @After
    public void tearDown()
    {
    }

    @Test
    public void testCreateEmployee()
    {
      assertEquals("Anders", addressC1.getPerson(1).getName()); //virker. Testen melder fejl, hvis man forsøger at sammenligne med et andet navn end det rigtige.
    }

    @Test
    public void testCreateCustomer()
    {
       assertEquals("Lars", addressC1.getPerson(2).getName());   //virker
    }
    
    /**
     *  Testing that customer is still a employee in card index or that he/she has been deleted succesfully.
     */
    @Test
    public void testDeleteEmployee()
    {
      assertNull(addressC1.getPerson(3)); //virker 
    }
    
    /**
     *  Testing that customer is still a customer in card index or that he/she has been deleted succesfully.
     */
    @Test
    public void testDeleteCustomer()
    {
      assertNull(addressC1.getPerson(4)); //virker 
    }
    
 }
  



